package com.kob.backend.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.kob.backend.pojo.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserMapper extends BaseMapper<User> {

    @Select("        SELECT \n" +
            "            FIND_IN_SET(u.rating, (SELECT GROUP_CONCAT(rating ORDER BY rating DESC) FROM user)) AS ranking\n" +
            "        FROM \n" +
            "            user u\n" +
            "        WHERE \n" +
            "            u.id = #{id}")
    Integer getRatingRanking(Integer id);
}
